public class AccountExtension {
    
    private Account a;
    
    public AccountExtension(ApexPages.StandardController stdController) {
        //a = (Account)stdController.getRecord();
        a = [select id,name,parentid from Account where account.Name='United Oil & Gas, UK' LIMIT 1];
    }

    public String getOpportunities(){
    	List<Opportunity> opportunities = [SELECT Name, Amount 
        				 				   FROM Opportunity
        				 				   WHERE AccountId = :a.Id];
        				 				   
        List<Account> accounts= [Select a.ShippingPostalCode, a.BillingPostalCode From Account a where ShippingPostalCode like '%ABC%'];
        for (Account acc: accounts){
        	System.debug('Shiiping:= '+ acc.ShippingPostalCode);
        	System.debug('Billing:= '+ acc.BillingPostalCode);
        	
        	String str= 'aaABC';
        	System.debug('BEFORE:= '+str);
        	str.replace('ABC', '');
        	System.debug('AFTER:= '+str);
        }		 				   
    	GoogleViz gv = new GoogleViz();
        gv.cols = new list<GoogleViz.col> { 
			new GoogleViz.Col('col1','Opportunity Name','string'),
		    new GoogleViz.Col('col2','Amount','number')
        };
         
        for(Opportunity o : opportunities){
			
			GoogleViz.row r = new GoogleViz.row();
            r.cells.add ( new GoogleViz.cell( o.Name ) );
            r.cells.add ( new GoogleViz.cell( o.Amount ) );
                
            gv.addRow( r );
        }

        return gv.toJsonString();
	}
	
	 public static testMethod void testGetOpportunities() {
        // Create our test data
        String expectedJSON = '{cols: [{id: "col1", label: "Opportunity Name", type: "string"},{id: "col2", label: "Amount", type: "number"}], ' + 
        					  'rows: [{c:[{v: "Test Opportunity"},{v: 10000.0}]}]}';
        
        Account a = new Account(name='Test Account');
        insert a;
        Opportunity o = new Opportunity(Name='Test Opportunity', Amount=10000, StageName='Prospecting', CloseDate=Date.today(), AccountId=a.Id);
        insert o;
        
        // Instantiate and construct the standard controller and extension classes.   
        ApexPages.StandardController stdController = new ApexPages.StandardController(a);
        AccountExtension extController = new AccountExtension(stdController);
		
		// Retrieve the JSON
		String actualJSON = extController.getOpportunities();
        
      	System.assertEquals(expectedJSON, actualJSON);
    }
}